<?php
if ( !defined( 'TOBBIVM' ) )
	header( 'location:/admin/template/notepassing.php' );
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Create price browse page
 * get pricelist.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
db::getInstance()->where('price_art', '1', '!=');
db::getInstance()->orderBy('price_name', 'ASC');
$result = db::getInstance()->get('price');

if (db::getInstance()->count <= 0)
{
	message::setErrorRow(_('Databaseerror! - Contact Admin!'), true);
}
else
{
	$refPage->assign('page_title', _('Price settings'));
	$refPage->assign('summary', _('This table gives a overview of the price lists'));

	$refPage->assign('price_id', _('ID'));
	$refPage->assign('price_name', _('Name'));

	$refPage->assign('Form_Start', '<form class="niceform fieldset pricelistTable" action="' .
	 'index2.php?page=' . $page . '&sub=' . $subpage .
	 '" method="post"><fieldset>');
	$refPage->assign('Form_End', '</fieldset></form>');
	$data = NULL;
	
	foreach ($result as $buffer)
	{
		$price_namey = '<a href="index2.php?page=' . $page . '&sub=' . $subpage .
		 '&id=' . $buffer['price_id'] . '&func=edit">' . $buffer['price_name'] . '</a>';

		$data[] = array('price_setx' => '<input type="checkbox" name="marker[]" value="' .
		 $buffer['price_id'] . '" />',
		 'price_idx' => $buffer['price_id'],
		 'price_namex' => $price_namey );
	}

	$refPage->assign('data', $data);

	$refPage->assign('btn_Delete', '<input type="submit" name="submit" id="delete" value="' .
	 _('Delete') . '" />');
	$refPage->assign('btn_New', '<input type="submit" name="submit" id="new" value="' .
	 _('New') . '" />');
	$refPage->assign('tableHelp', help('pricelist', $page, TRUE));

	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.tpl.php');
}
?>